$(function () {
vm.reload();
});

var vm = new Vue({
	el:'#rrapp',
	data:{
	    searchList:[],
        searchName:''
	},
	methods: {
		del: function (id) {
		    var ids=[];
		    ids.push(id);
			confirm('确定要删除？', function(){
				$.ajax({
					type: "POST",
				    url: baseURL + "sys/search/delete",
                    contentType: "application/json",
				    data: JSON.stringify(ids),
				    success: function(r){
						if(r.code == 0){
							alert('操作成功', function(index){
								vm.reload();
							});
						}else{
							alert(r.msg);
						}
					}
				});
			});
		},
        addNewWord:function () {
            if(vm.searchName==null||vm.searchName==''){
                alert("请输入搜索词");
                return;
            }
            $.ajax({
            	type: "POST",
                url: baseURL + "sys/search/save",
               contentType: "application/json",
                data: JSON.stringify({name:vm.searchName}),
                success: function(r){
                	if(r.code === 0){
            			alert('操作成功', function(index){
            				vm.reload();
            			});
            		}else{
            			alert(r.msg);
            		}
            	}
            });
        },
        reload:function () {
            vm.searchName="";
            $.ajax({
                type: "POST",
                url: baseURL + "sys/search/listAll",
                contentType: "application/json",
                data: JSON.stringify({}),
                success: function(r){
                    if(r.code === 0){
                        vm.searchList=r.list;
                    }else{
                        alert(r.msg);
                    }
                }
            });
        }
	}
});